package acm.蓝桥12;

import java.util.Scanner;

public class J乘积等于和 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums=new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i]=sc.nextInt();
        }
        long res=0;
        for (int i = 0; i < n; i++) {
            long sum=nums[i];
            long mut=nums[i];
            for (int j = i+1; j < n; j++) {
                sum+=nums[j];
                mut*=nums[j];
                if (sum==mut){
                    res++;
                }
            }
            res++;
        }
        System.out.println(res);
    }
}
